/*
 * Copyright © 2022-now 尛飛俠（Denvie） All rights reserved.
 */

package cn.denvie.springcloud.user.config;

import cn.denvie.springcloud.user.interceptor.BasicAuthenticateInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * UserCenterWebMvcConfig。
 *
 * @author Denvie
 * @date 2022/3/30
 * @since 1.0.0
 */
@Configuration
public class UserCenterWebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private BasicAuthenticateInterceptor basicAuthenticateInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(basicAuthenticateInterceptor);
        /*
        SentinelWebMvcConfigurer 在 SentinelWebAutoConfiguration 中已自动装配，但未生效，
        这里通过手动调用 sentinelWebMvcConfigurer.addInterceptors() 添加解决
         */
        // getApplicationContext().getBean(SentinelWebMvcConfigurer.class).addInterceptors(registry);
    }
}
